$(document).ready(function () {
    var str = `<div>
				  <input class="cl_user_name" type="text" placeholder="用户名"/>
				  <i class="fa fa-user-circle-o" aria-hidden="true"></i>
				</div>
				
				<div>
					<input class="cl_password" type="password" placeholder="密码"/>
					<i class="fa fa-unlock-alt" aria-hidden="true"></i>
				</div><br/>
				<div>
					<input class="cl_login" style="text-indent:0;" type="button" value="登录" />
				</div>`;

    $('.bg_img2').html(str);
    $('.cl_login').click(function () {
        var system = {
            win: false,
            mac: false,
            xll: false
        };
        //检测平台
        var p = navigator.platform;

        var login_infor;//当前浏览器
        system.win = p.indexOf("Win") == 0;
        system.mac = p.indexOf("Mac") == 0;
        system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
        if (system.win || system.mac || system.xll) {
            var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串

            var Opera = userAgent.indexOf("OPR") > -1; //判断是否Opera浏览器

            var IE = userAgent.indexOf(".NET") > -1; //判断是否IE的Edge浏览器
            var Firefox = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
            var Safari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
            var Chrome = userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("Safari") > -1; //判断Chrome浏览器
            var Edge = userAgent.indexOf("Edge") > -1; //判断是否IE浏览器
            Opera ? login_infor = 'Opera' : 0;
            IE ? login_infor = 'IE' : 0;

            Firefox ? login_infor = 'Firefox' : 0;
            Safari ? login_infor = 'Safari' : 0;
            Chrome ? login_infor = 'Chrome' : 0;
            Edge ? login_infor = 'Edge' : 0;
            console.log(login_infor)

        } else {
            var appVersion = navigator.appVersion;
            if (appVersion.indexOf('iPhone') > -1) {
                login_infor = 'iPhone';
            } else {
                login_infor = 'Android'
            }

        }

        $.ajax({
            type: "get",
            headers: {
                Accept: "application/json; charset=utf-8"
            },
            url: "http://www.puer.zone:30000/UserLogin",
            data: {
                user_name: $('.cl_user_name').val(),
                user_password: $('.cl_password').val(),
            },
            success: function (data) {
                if (data[0] == 'success') {
                    $.cookie('UserId', data[1][0], {expires: 1});
                    $.cookie('UserRight', data[1][1], {expires: 1});


                    layer.msg('登录成功', {time: 500}, function () {
                        if (data[1][1] == 4) {
                            $.cookie('UserRightText', '订单管理员', {expires: 1});
                            window.location.href = 'http://www.puer.zone:9000/hire_order.html';
                        } else if (data[1][1] == 3) {
                            $.cookie('UserRightText', '商品管理员', {expires: 1});
                            window.location.href = 'http://www.puer.zone:9000/product_list.html';
                        } else if (data[1][1] == 2) {
                            $.cookie('UserRightText', '普通管理员', {expires: 1});
                            window.location.href = 'http://www.puer.zone:9000/id_manager.html';
                        } else {
                            $.cookie('UserRightText', '高级管理员', {expires: 1});
                            window.location.href = 'http://www.puer.zone:9000/id_manager.html';
                        }
                    })
                } else {
                    layer.msg('登录失败，账号或密码错误')
                }

            }
        });
    })


})